//
//  RelatedAdviViewController.m
//  WE
//
//  Created by iMacOne on 15/11/21.
//  Copyright © 2015年 UNOHACHA. All rights reserved.
//

#import "RelatedAdviViewController.h"
#import "Size.h"
#import "ToolUtil.h"
#import "MoreRelatedAdviCell.h"
#import "MoreAdviViewController.h"
@interface RelatedAdviViewController ()
@property (nonatomic, strong)UITableView * tableView;

@end

@implementation RelatedAdviViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"相关资讯";
    [self.view addSubview:self.tableView];
    [self creatBottomView];
    [self.tableView registerClass:[MoreRelatedAdviCell class] forCellReuseIdentifier:@"MoreRelatedAdviCell"];
    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.tableView setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
        [self.tableView setLayoutMargins:UIEdgeInsetsZero];
    }
}
- (void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.hidden = NO;
    
}

- (void)creatBottomView
{
    UIView *broundView = [[UIView alloc] initWithFrame:CGRectMake(0, WindowHeight - 49, WindowWidth, 49)];
    broundView.backgroundColor = [UIColor whiteColor];
//    NSArray * arr = @[@"杭州",@"默认排序"];
    // broundView.backgroundColor = [UIColor grayColor];
    [ToolUtil createLine:0 superView:broundView lift:0 width:WindowWidth hight:1 color:[UIColor grayColor]];
//    [ToolUtil createVerticalLine:0 superView:broundView lift:WindowWidth/2 height:49];
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(10, 5, WindowWidth-20, 40);
    btn.titleLabel.font = FONT(12);
    UIImageView * imageV = [[UIImageView alloc] initWithFrame:CGRectMake((btn.frame.size.width - 130)/2, 10, 20, 20)];
    imageV.image = [UIImage imageNamed:@"search"];
//    imageV.backgroundColor = DEBUG_CLOLR;
    
    
    UILabel * lbl = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(imageV.frame )+ 20, 5, 60, 30)];
    lbl.text = @"找专家咨询";
    lbl.textColor = [UIColor whiteColor];
    lbl.font = FONT(12);
    
    [btn addSubview:imageV];
    [btn addSubview:lbl];

    btn.tag = 100;
    btn.layer.masksToBounds = YES;
    btn.layer.cornerRadius = 2;
    btn.backgroundColor = [UIColor orangeColor];
    
    [btn addTarget:self action:@selector(pressButton:) forControlEvents:UIControlEventTouchUpInside];
    [broundView addSubview:btn];
    [self.view addSubview:broundView];
}
- (void)pressButton:(UIButton *)btn
{
    MoreAdviViewController * adviVC = [[MoreAdviViewController alloc] init];
    [self.navigationController pushViewController:adviVC animated:YES];
}
- (UITableView *)tableView
{
    if (_tableView == nil) {
        self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0 ,WindowWidth , WindowHeight- 49) style:UITableViewStylePlain];
        _tableView.dataSource = self;
        _tableView.delegate = self;
        _tableView.rowHeight = 180;
        _tableView.showsVerticalScrollIndicator = NO;

        //        _tableView.scrollEnabled = NO;
    }
    return _tableView;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 6;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    static NSString * cellIdentifier = @"MoreRelatedAdviCell";
    MoreRelatedAdviCell * cell = [[MoreRelatedAdviCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
 
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    
    
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

@end
